/// <reference path="references.scss" />

// General
// =================================

.label-cart-amount {
    //--badge-font-size: 10px;
    position: absolute;
    inset-inline-end: -5px;
    top: -9px;
}


// OffCanvas Cart
// =================================

#offcanvas-cart {
    .offcanvas-content {
        display: flex;
        flex-direction: column;
    }

    .tab-content {
        position: absolute;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;
    }

    .tab-pane {
        padding: 0;
        position: absolute;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0;

        &.active {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
        }

        > * { width: 100%; z-index: 1; }
    }

    .price {
        white-space: nowrap;
        font-weight: $font-weight-medium;
    }

    .throbber {
        background-color: #fff;
    }
}

.offcanvas-cart-content {
    position: relative;
    flex-grow: 1;
}

.offcanvas-cart-body {
    position: relative;
    flex-grow: 1;
	min-height: 100px;

    .no-items {
	    margin: 2rem 1rem;
	    text-align: center;

        .no-item-title, .no-item-icon { margin-bottom: 1rem; }

        .no-item-title  { font-size: $h2-font-size; font-weight: 400; }
        .no-item-icon   { color: rgba(0,0,0, 0.15); }
        .no-item-info   { color: $text-muted; .fa { color: $body-color; } }
    }
}

.offcanvas-cart-item {
    border-bottom: 1px solid rgba(#000, 0.15);
    padding: $grid-gutter-width / 1.5;

    &:last-child { border-width: 0; }

    .col-alpha {
        width: 100px;
        min-width: 100px;
        max-width: 100px;
    }

    .col-data {
        line-height: 1.3;
    }

    .col-data > * {
        display: block;
        margin-bottom: 0.5rem;
    }

    .name { color: $body-color; }

    .unit-price { font-size: 1.25rem; line-height: 1.8; }

    .pangv { 
        font-size: $font-size-sm;
        color: $text-muted;
    }

	.qty-input .form-control {
		border-color: transparent;
	}
    .mb-bundle-pictures {
        a, .fa {
            padding-inline-end: 3px;
        }
        .fa {
            font-size: 0.625rem;
        }
        a:hover {
            text-decoration: none;
        }
    }

    @media (max-width: 360px) {
        .unit-price { font-size: 1rem; }
    }
}

.offcanvas-cart-footer {
    background-color: $offcanvas-cart-footer;
}

.offcanvas-cart-footer-row {
    display: flex; 
    justify-content: space-between;
    align-items: center;
    line-height: 1.1;
    color: #fff;
    padding: 1rem;

    .sub-total-caption {
        text-transform: uppercase; 
        font-size: 0.8rem; 
    }

    .sub-total {
        font-size: 1.5rem;
    }
}

.offcanvas-cart-external-checkout {
    .heading-center:before {
        background: rgba(#fff, 0.4) !important;
        width: calc(100% - 2rem);
    }

    .heading-title {
        background-color: $offcanvas-cart-footer;
        color: rgba(#fff, 0.8);
        margin-bottom: 0;
        text-transform: uppercase;
    }

    > div:not(:empty) {
        padding: 0.5rem 1rem;
    }
}

// Full Cart
// =================================

.cart-container {
    --cart-row-padding-x: 1.25rem;
    --cart-row-padding-y: 1.25rem;
    --cart-border-radius: var(--border-radius-md);
    --cart-border-color: var(--border-color);
    --cart-item-img-width: 96px;
    --cart-item-title-font-size: 1rem;
    --cart-footer-bg: #{$cart-footer-bg};
    --cart-child-row-bg: #{tint-color($gray-100, 40%)};

    --pd-finalprice-font-size: 1.25rem;
    --pd-finalprice-color: inherit;
    --pd-finalprice-offer-color: inherit;
    --pd-offer-muted-color: var(--gray-650, var(--gray-600));
}

.cart {
    width: 100%;
    max-width: 100%;
}

#cart-items,
.bottom-order-total-container {
    border-radius: var(--cart-border-radius);
    border: 1px solid var(--cart-border-color);
}

#cart-items {
    @include border-bottom-radius(0);
}

.cart-row {
    position: relative;
    padding: var(--cart-row-padding-y) var(--cart-row-padding-x);

    &:not(:first-child) {
        border-top: 1px solid $gray-300;
    }

    .qty-input-dropdown {
        max-width: 140px;
    }

    .qty-input-spinner {
        width: 92px;
    }
}

.cart-item-group:not(:last-child) {
    margin-bottom: 0.625rem;
}

.cart-item-img {
    text-align: center;
}

.cart-item-brand {
    color: var(--secondary-color);
    position: relative;
    margin-bottom: 0.5rem;
}

.cart-item-brand-image {
    display: inline-block;
    max-width: 100%;
    height: auto;
    max-height: 24px;
}

.cart-item-title {
    display: flex;
    align-items: center;
    justify-content: start;
    gap: 0.5rem;
    width: 100%;
    font-weight: $font-weight-medium;
    font-size: var(--cart-item-title-font-size);
    line-height: 1.3;
}

.cart-item-desc {
    color: var(--secondary-color);
}

.cart-item-bundle-img {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: start;
}

.cart-item-link {
    @extend .link-body;
    @extend .link-dnu;
    @extend .link-transition;
}

.cart-item-attrs {
    display: grid !important;
    grid-template-columns: fit-content(50%) fit-content(50%); 
    gap: 4px 12px;
    line-height: 1.2;

    > span:nth-child(odd) {
        font-weight: $font-weight-medium;
    }
}

.select-cart-item {
    display: flex;

    @include media-breakpoint-up(md) {
        align-items: center;
    }
}

.select-cart-item-checkbox {
    --form-check-checked-bg-rgb: var(--gray-rgb);
}

.cart-item-actions {
    gap: 0.5rem;
}

.cart-row-child {
    --cart-item-title-font-size: #{$font-size-base};
    --pd-finalprice-font-size: 1rem;
    --pd-offer-font-size-sm: #{$font-size-xs};

    font-size: 90%;
    background: var(--cart-child-row-bg);
    border-top-width: 0 !important;

    + .cart-row-child {
        // Collapse neighbours
        padding-top: 0;
    }
}

.cart-footer {
    position: sticky; 
    top: 16px;
    bottom: 0;
    background-color: var(--cart-footer-bg);
    padding: 1.25rem;
    border-radius: var(--cart-border-radius);

    .alert {
        --alert-border-color: #{rgba($black, 0.08)};
    }
}

.cart-footer-group + .cart-footer-group {
    position: relative;
    padding-top: 1rem;
    margin-top: 0.5rem;

    &:before {
        // Divider
        position: relative;
        display: block;
        width: 100%;
        height: 1px;
        top: -1rem;
        content: ' ';
        background-color: rgba($black, 0.08);
    }
}

.cart-summary {
    width: 100%;
    line-height: 1.3;

    td {
        padding: 0.4rem 0;
        vertical-align: top;
    }

    .cart-summary-label {
        padding-inline-end: 0.5rem;
    }

    .cart-summary-value {
        text-align: end;
        white-space: nowrap;
    }

    .cart-summary-pos {
        color: var(--success-text-emphasis);
        > .cart-summary-value {
            font-weight: $font-weight-medium;
        }
    }

    .cart-summary-neg {
        color: var(--danger-text-emphasis);
    }

    .cart-summary-total {
        font-size: $font-size-lg;
        font-weight: $font-weight-medium;

        td { padding-top: 0.75rem; }
    }

    .cart-summary-giftcard br {
        display: none;
    }
}

.cart-checkout-attributes {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba($black, 0.12);
}


.order-summary-content .selected-checkout-attributes,
.page-order-details .cart-checkout-attrs {
	.attr-caption {
		font-weight: $font-weight-medium;
		padding-inline-end: 10px;
		&:after {
			content: ': ' 
		}
	}
	.attr-value {
		text-align: start;
	}
}

.table-order-products .productpicture,
.table-order-products .remove,
.table-order-products .addtocart {
    text-align: center;
}


// Bottom order total
// =================================

.bottom-order-total-container {
    background-color: var(--cart-footer-bg);
    border-top-width: 0;
    @include border-top-radius(0);
}

.bottom-order-total {
    display: grid;
    grid-template-columns: max-content max-content;
    gap: 8px 12px;

    .total-item:nth-child(even) {
        justify-self: end;
    }
}


// Collapsible cart action boxes
// =================================

.cart-action {
    position: relative;

    .cart-action-title {
        position: relative;
        cursor: pointer;
        padding: 0.5rem 0;
        margin: 0;

        &:after {
            @include fontawesome("\f106");
            position: absolute;
            inset-inline-end: 0;
            top: 50%;
            transform: translateY(-50%) rotate(0);
            transition: transform 0.15s linear;
        }

        &.collapsed:after {
            //content: "\f107";
            transform: translateY(-50%) rotate(180deg);
        }
    }

    .cart-action-body {
        padding-top: 0.5rem;
        padding-bottom: 1rem;

        .form-group:last-child {
            margin-bottom: 0;
        }
    }

    &:first-child .cart-action-title {
        padding-top: 0;
    }
}


// Responsiveness
// =================================

@include media-breakpoint-down(md) {
    // Collapse items and summary

    .cart-footer {
        @include border-top-radius(0);
        border: 1px solid var(--cart-border-color);

        &:not(.cart-footer-panel) {
            border-top-width: 0;
        }
    }

    .bottom-order-total-container {
        display: none;
    }
}

@include media-breakpoint-up(md) {
    .cart {
        --cart-item-img-width: 128px;
    }
}

@include media-breakpoint-up(lg) {
    .cart {
        --cart-item-img-width: 96px;
    }
}

@include media-breakpoint-up(xl) {
    .cart {
        --cart-item-img-width: 128px;
    }
}